﻿#pragma once
#include "DataObject.h"
#include "Types.h"
#include <vtkm/exec/ParametricCoordinates.h>
#include <vtkm/worklet/WorkletMapTopology.h>

/// @brief 采用CRTP抽象初始条件的基类，子类实现`ComputeValue`接口
/// @tparam Derived 
template<typename Derived>
struct WorkletInitCondition : vtkm::worklet::WorkletVisitCellsWithPoints
{
  using ControlSignature = void(CellSetIn, FieldOut, FieldInPoint);
  using ExecutionSignature = void(CellShape, _2, _3);

  using ValueType = Vec<FloatDefault, 5>;

  template<typename CellShapeTag, typename VType, typename PType>
  VTKM_EXEC void operator()(const CellShapeTag& shape, VType& value, const PType& pts) const
  {
    vtkm::Vec3f wpoint, lpoint;
    vtkm::exec::ParametricCoordinatesCenter(pts.GetNumberOfComponents(), shape, lpoint);
    //vtkm::exec::ParametricCoordinatesToWorldCoordinates(pts, lpoint, shape, wpoint);
    auto p = (pts[0] + pts[1] + pts[2] + pts[3]) / 4;
    value = static_cast<const Derived*>(this)->ComputeValue(p);
  }
};

class InitialCondition
{
public:
  InitialCondition(){};
  ~InitialCondition(){};

  virtual void Execute() = 0;

private:
};

